package com.fxu.framework.core.sql;

import com.fxu.framework.core.enums.BaseEnum;

import java.io.Serializable;

/**
 * join 类型
 * @author fangxu
 * @version 1.6.1
 */
public enum JoinType implements Serializable {
//    /**
//     * full join, mysql 8 暂时不支持full join, 得用 union
//     */
//    FULL,
    /**
     * left join
     */
    LEFT,
    /**
     * right join
     */
    RIGHT,
    /**
     * inner join
     */
    INNER,
    /**
     * select * from * where in (select *)
     */
    INSQL,
    /**
     * select * from * where not in (select *)
     */
    NOTINSQL;

    public static JoinType find(String name) {
        return name == null ? null : BaseEnum.findOne(values(), v -> v.name().equalsIgnoreCase(name));
    }

    public static boolean isJoin(JoinType joinType) {
        return joinType == LEFT || joinType == RIGHT || joinType == INNER;
    }
}